package palmtop.com.palmtop.activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.Toast;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.download.ImageDownloader;

import palmtop.com.palmtop.R;

/**
 * Created by Administrator on 2017/9/23.
 */
public class ImageDetailActivity extends Activity {

    private ZoomImageView zoomImageView;
    String imagePath;
   MyZoomImageView imageView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_layout);
        imagePath = getIntent().getStringExtra("picpath");
        imageView = (MyZoomImageView) findViewById(R.id.zoom_image_view);
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.loading)
                .showImageOnFail(R.mipmap.notfound)
                .cacheInMemory(true)
                .cacheOnDisc(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .build();
        if(imagePath!=null){
            if(imagePath.indexOf("http")!=-1){
                ImageLoader.getInstance().displayImage(imagePath, imageView,options);
            }else{
                String imageUrl = ImageDownloader.Scheme.FILE.wrap(imagePath);
                ImageLoader.getInstance().displayImage(imageUrl, imageView,options);
            }
        }else{
            Toast.makeText(getApplicationContext(), "图片地址不能为空", Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}
